<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
<!-- qpolygon.cpp -->
  <title>QPolygon Class | Qt GUI 5.14.2</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.14</a></td><td ><a href="qtgui-index.html">Qt GUI</a></td><td ><a href="qtgui-module.html">C++ Classes</a></td><td >QPolygon</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtgui-index.html">Qt 5.14.2 Reference Documentation</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#related-non-members">Related Non-Members</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QPolygon Class</h1>
<!-- $$$QPolygon-brief -->
<p>The QPolygon class provides a vector of points using integer precision. <a href="#details">More...</a></p>
<!-- @@@QPolygon -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QPolygon&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += gui</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="../qtcore/qvector.html">QVector</a></td></tr></table></div><ul>
<li><a href="qpolygon-members.html">List of all members, including inherited members</a></li>
</ul>
<p><b>Note:</b> All functions in this class are <a href="../qtdoc/threads-reentrancy.html">reentrant</a>.</p>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#QPolygon">QPolygon</a></b>(const QPolygon &amp;<i>polygon</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#QPolygon-4">QPolygon</a></b>(const QRect &amp;<i>rectangle</i>, bool <i>closed</i> = false)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#QPolygon-2">QPolygon</a></b>(const QVector&lt;QPoint&gt; &amp;<i>points</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#QPolygon-1">QPolygon</a></b>(int <i>size</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#QPolygon">QPolygon</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#dtor.QPolygon">~QPolygon</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QRect </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#boundingRect">boundingRect</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#containsPoint">containsPoint</a></b>(const QPoint &amp;<i>point</i>, Qt::FillRule <i>fillRule</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPolygon </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#intersected">intersected</a></b>(const QPolygon &amp;<i>r</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#intersects">intersects</a></b>(const QPolygon &amp;<i>p</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#point">point</a></b>(int <i>index</i>, int *<i>x</i>, int *<i>y</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPoint </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#point-1">point</a></b>(int <i>index</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#putPoints">putPoints</a></b>(int <i>index</i>, int <i>nPoints</i>, const QPolygon &amp;<i>fromPolygon</i>, int <i>fromIndex</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#putPoints">putPoints</a></b>(int <i>index</i>, int <i>nPoints</i>, int <i>firstx</i>, int <i>firsty</i>, <i>...</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#setPoint">setPoint</a></b>(int <i>index</i>, int <i>x</i>, int <i>y</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#setPoint-1">setPoint</a></b>(int <i>index</i>, const QPoint &amp;<i>point</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#setPoints">setPoints</a></b>(int <i>nPoints</i>, const int *<i>points</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#setPoints-1">setPoints</a></b>(int <i>nPoints</i>, int <i>firstx</i>, int <i>firsty</i>, <i>...</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPolygon </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#subtracted">subtracted</a></b>(const QPolygon &amp;<i>r</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#swap">swap</a></b>(QPolygon &amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#translate">translate</a></b>(int <i>dx</i>, int <i>dy</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#translate-1">translate</a></b>(const QPoint &amp;<i>offset</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPolygon </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#translated">translated</a></b>(int <i>dx</i>, int <i>dy</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPolygon </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#translated-1">translated</a></b>(const QPoint &amp;<i>offset</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPolygon </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#united">united</a></b>(const QPolygon &amp;<i>r</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QVariant </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#operator-QVariant">operator QVariant</a></b>() const</td></tr>
</table></div>
<a name="related-non-members"></a>
<h2 id="related-non-members">Related Non-Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> QDataStream &amp;</td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#operator-lt-lt-14">operator&lt;&lt;</a></b>(QDataStream &amp;<i>stream</i>, const QPolygon &amp;<i>polygon</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QDataStream &amp;</td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#operator-gt-gt">operator&gt;&gt;</a></b>(QDataStream &amp;<i>stream</i>, QPolygon &amp;<i>polygon</i>)</td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QPolygon-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>A QPolygon object is a <a href="../qtcore/qvector.html">QVector</a>&lt;<a href="../qtcore/qpoint.html">QPoint</a>&gt;. The easiest way to add points to a QPolygon is to use <a href="../qtcore/qvector.html">QVector</a>'s streaming operator, as illustrated below:</p>
<pre class="cpp">

          <span class="type"><a href="qpolygon.html#QPolygon">QPolygon</a></span> polygon;
          polygon <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span>(<span class="number">10</span><span class="operator">,</span> <span class="number">20</span>) <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span>(<span class="number">20</span><span class="operator">,</span> <span class="number">30</span>);

</pre>
<p>In addition to the functions provided by <a href="../qtcore/qvector.html">QVector</a>, QPolygon provides some point-specific functions.</p>
<p>Each point in a polygon can be retrieved by passing its index to the <a href="qpolygon.html#point">point</a>() function. To populate the polygon, QPolygon provides the <a href="qpolygon.html#setPoint">setPoint</a>() function to set the point at a given index, the <a href="qpolygon.html#setPoints">setPoints</a>() function to set all the points in the polygon (resizing it to the given number of points), and the <a href="qpolygon.html#putPoints">putPoints</a>() function which copies a number of given points into the polygon from a specified index (resizing the polygon if necessary).</p>
<p>QPolygon provides the <a href="qpolygon.html#boundingRect">boundingRect</a>() and <a href="qpolygon.html#translate">translate</a>() functions for geometry functions. Use the <a href="qmatrix.html#map">QMatrix::map</a>() function for more general transformations of QPolygons.</p>
<p>The QPolygon class is <a href="../qtcore/implicit-sharing.html">implicitly shared</a>.</p>
</div>
<p><b>See also </b><a href="../qtcore/qvector.html">QVector</a>, <a href="qpolygonf.html">QPolygonF</a>, and <a href="../qtcore/qline.html">QLine</a>.</p>
<!-- @@@QPolygon -->
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QPolygon[overload1]$$$QPolygonconstQPolygon& -->
<h3 class="fn" id="QPolygon"><a name="QPolygon"></a>QPolygon::<span class="name">QPolygon</span>(const <span class="type"><a href="qpolygon.html#QPolygon">QPolygon</a></span> &amp;<i>polygon</i>)</h3>
<p>Constructs a copy of the given <i>polygon</i>.</p>
<p><b>See also </b><a href="qpolygon.html#setPoints">setPoints</a>().</p>
<!-- @@@QPolygon -->
<!-- $$$QPolygon$$$QPolygonconstQRect&bool -->
<h3 class="fn" id="QPolygon-4"><a name="QPolygon-4"></a>QPolygon::<span class="name">QPolygon</span>(const <span class="type"><a href="../qtcore/qrect.html">QRect</a></span> &amp;<i>rectangle</i>, <span class="type">bool</span> <i>closed</i> = false)</h3>
<p>Constructs a polygon from the given <i>rectangle</i>. If <i>closed</i> is false, the polygon just contains the four points of the rectangle ordered clockwise, otherwise the polygon's fifth point is set to <i>rectangle</i>.topLeft().</p>
<p>Note that the bottom-right corner of the rectangle is located at (rectangle.x() + rectangle.width(), rectangle.y() + rectangle.height()).</p>
<p><b>See also </b><a href="qpolygon.html#setPoints">setPoints</a>().</p>
<!-- @@@QPolygon -->
<!-- $$$QPolygon$$$QPolygonconstQVector<QPoint>& -->
<h3 class="fn" id="QPolygon-2"><a name="QPolygon-2"></a>QPolygon::<span class="name">QPolygon</span>(const <span class="type"><a href="../qtcore/qvector.html#QVector">QVector</a></span>&lt;<span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span>&gt; &amp;<i>points</i>)</h3>
<p>Constructs a polygon containing the specified <i>points</i>.</p>
<p><b>See also </b><a href="qpolygon.html#setPoints">setPoints</a>().</p>
<!-- @@@QPolygon -->
<!-- $$$QPolygon$$$QPolygonint -->
<h3 class="fn" id="QPolygon-1"><a name="QPolygon-1"></a>QPolygon::<span class="name">QPolygon</span>(<span class="type">int</span> <i>size</i>)</h3>
<p>Constructs a polygon of the given <i>size</i>. Creates an empty polygon if <i>size</i> == 0.</p>
<p><b>See also </b><a href="../qtcore/qvector.html#isEmpty">QVector::isEmpty</a>().</p>
<!-- @@@QPolygon -->
<!-- $$$QPolygon[overload1]$$$QPolygon -->
<h3 class="fn" id="QPolygon"><a name="QPolygon"></a>QPolygon::<span class="name">QPolygon</span>()</h3>
<p>Constructs a polygon with no points.</p>
<p><b>See also </b><a href="../qtcore/qvector.html#isEmpty">QVector::isEmpty</a>().</p>
<!-- @@@QPolygon -->
<!-- $$$~QPolygon[overload1]$$$~QPolygon -->
<h3 class="fn" id="dtor.QPolygon"><a name="dtor.QPolygon"></a>QPolygon::<span class="name">~QPolygon</span>()</h3>
<p>Destroys the polygon.</p>
<!-- @@@~QPolygon -->
<!-- $$$boundingRect[overload1]$$$boundingRect -->
<h3 class="fn" id="boundingRect"><a name="boundingRect"></a><span class="type"><a href="../qtcore/qrect.html">QRect</a></span> QPolygon::<span class="name">boundingRect</span>() const</h3>
<p>Returns the bounding rectangle of the polygon, or <a href="../qtcore/qrect.html">QRect</a>(0, 0, 0, 0) if the polygon is empty.</p>
<p><b>See also </b><a href="../qtcore/qvector.html#isEmpty">QVector::isEmpty</a>().</p>
<!-- @@@boundingRect -->
<!-- $$$containsPoint[overload1]$$$containsPointconstQPoint&Qt::FillRule -->
<h3 class="fn" id="containsPoint"><a name="containsPoint"></a><span class="type">bool</span> QPolygon::<span class="name">containsPoint</span>(const <span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> &amp;<i>point</i>, <span class="type"><a href="../qtcore/qt.html#FillRule-enum">Qt::FillRule</a></span> <i>fillRule</i>) const</h3>
<p>Returns <code>true</code> if the given <i>point</i> is inside the polygon according to the specified <i>fillRule</i>; otherwise returns <code>false</code>.</p>
<p>This function was introduced in Qt 4.3.</p>
<!-- @@@containsPoint -->
<!-- $$$intersected[overload1]$$$intersectedconstQPolygon& -->
<h3 class="fn" id="intersected"><a name="intersected"></a><span class="type"><a href="qpolygon.html#QPolygon">QPolygon</a></span> QPolygon::<span class="name">intersected</span>(const <span class="type"><a href="qpolygon.html#QPolygon">QPolygon</a></span> &amp;<i>r</i>) const</h3>
<p>Returns a polygon which is the intersection of this polygon and <i>r</i>.</p>
<p>Set operations on polygons will treat the polygons as areas. Non-closed polygons will be treated as implicitly closed.</p>
<p>This function was introduced in Qt 4.3.</p>
<p><b>See also </b><a href="qpolygon.html#intersects">intersects</a>().</p>
<!-- @@@intersected -->
<!-- $$$intersects[overload1]$$$intersectsconstQPolygon& -->
<h3 class="fn" id="intersects"><a name="intersects"></a><span class="type">bool</span> QPolygon::<span class="name">intersects</span>(const <span class="type"><a href="qpolygon.html#QPolygon">QPolygon</a></span> &amp;<i>p</i>) const</h3>
<p>Returns <code>true</code> if the current polygon intersects at any point the given polygon <i>p</i>. Also returns <code>true</code> if the current polygon contains or is contained by any part of <i>p</i>.</p>
<p>Set operations on polygons will treat the polygons as areas. Non-closed polygons will be treated as implicitly closed.</p>
<p>This function was introduced in Qt 5.10.</p>
<p><b>See also </b><a href="qpolygon.html#intersected">intersected</a>().</p>
<!-- @@@intersects -->
<!-- $$$point[overload1]$$$pointintint*int* -->
<h3 class="fn" id="point"><a name="point"></a><span class="type">void</span> QPolygon::<span class="name">point</span>(<span class="type">int</span> <i>index</i>, <span class="type">int</span> *<i>x</i>, <span class="type">int</span> *<i>y</i>) const</h3>
<p>Extracts the coordinates of the point at the given <i>index</i> to *<i>x</i> and *<i>y</i> (if they are valid pointers).</p>
<p><b>See also </b><a href="qpolygon.html#setPoint">setPoint</a>().</p>
<!-- @@@point -->
<!-- $$$point$$$pointint -->
<h3 class="fn" id="point-1"><a name="point-1"></a><span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> QPolygon::<span class="name">point</span>(<span class="type">int</span> <i>index</i>) const</h3>
<p>This is an overloaded function.</p>
<p>Returns the point at the given <i>index</i>.</p>
<!-- @@@point -->
<!-- $$$putPoints[overload1]$$$putPointsintintconstQPolygon&int -->
<h3 class="fn" id="putPoints"><a name="putPoints"></a><span class="type">void</span> QPolygon::<span class="name">putPoints</span>(<span class="type">int</span> <i>index</i>, <span class="type">int</span> <i>nPoints</i>, const <span class="type"><a href="qpolygon.html#QPolygon">QPolygon</a></span> &amp;<i>fromPolygon</i>, <span class="type">int</span> <i>fromIndex</i> = 0)</h3>
<p>This is an overloaded function.</p>
<p>Copies <i>nPoints</i> points from the given <i>fromIndex</i> ( 0 by default) in <i>fromPolygon</i> into this polygon, starting at the specified <i>index</i>. For example:</p>
<pre class="cpp">

          <span class="type"><a href="qpolygon.html#QPolygon">QPolygon</a></span> polygon1;
          polygon1<span class="operator">.</span>putPoints(<span class="number">0</span><span class="operator">,</span> <span class="number">3</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span><span class="number">2</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span><span class="number">0</span><span class="operator">,</span> <span class="number">5</span><span class="operator">,</span><span class="number">6</span>);
          <span class="comment">// polygon1 is now the three-point polygon(1,2, 0,0, 5,6);</span>

          <span class="type"><a href="qpolygon.html#QPolygon">QPolygon</a></span> polygon2;
          polygon2<span class="operator">.</span>putPoints(<span class="number">0</span><span class="operator">,</span> <span class="number">3</span><span class="operator">,</span> <span class="number">4</span><span class="operator">,</span><span class="number">4</span><span class="operator">,</span> <span class="number">5</span><span class="operator">,</span><span class="number">5</span><span class="operator">,</span> <span class="number">6</span><span class="operator">,</span><span class="number">6</span>);
          <span class="comment">// polygon2 is now (4,4, 5,5, 6,6);</span>

          polygon1<span class="operator">.</span>putPoints(<span class="number">2</span><span class="operator">,</span> <span class="number">3</span><span class="operator">,</span> polygon2);
          <span class="comment">// polygon1 is now the five-point polygon(1,2, 0,0, 4,4, 5,5, 6,6);</span>

</pre>
<!-- @@@putPoints -->
<!-- $$$putPoints[overload1]$$$putPointsintintintint... -->
<h3 class="fn" id="putPoints"><a name="putPoints"></a><span class="type">void</span> QPolygon::<span class="name">putPoints</span>(<span class="type">int</span> <i>index</i>, <span class="type">int</span> <i>nPoints</i>, <span class="type">int</span> <i>firstx</i>, <span class="type">int</span> <i>firsty</i>, <i>...</i>)</h3>
<p>Copies <i>nPoints</i> points from the variable argument list into this polygon from the given <i>index</i>.</p>
<p>The points are given as a sequence of integers, starting with <i>firstx</i> then <i>firsty</i>, and so on. The polygon is resized if <code>index+nPoints</code> exceeds its current size.</p>
<p>The example code creates a polygon with three points (4,5), (6,7) and (8,9), by expanding the polygon from 1 to 3 points:</p>
<pre class="cpp">

          <span class="type"><a href="qpolygon.html#QPolygon">QPolygon</a></span> polygon(<span class="number">1</span>);
          polygon<span class="operator">[</span><span class="number">0</span><span class="operator">]</span> <span class="operator">=</span> <span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span>(<span class="number">4</span><span class="operator">,</span> <span class="number">5</span>);
          polygon<span class="operator">.</span>putPoints(<span class="number">1</span><span class="operator">,</span> <span class="number">2</span><span class="operator">,</span> <span class="number">6</span><span class="operator">,</span><span class="number">7</span><span class="operator">,</span> <span class="number">8</span><span class="operator">,</span><span class="number">9</span>);

</pre>
<p>The following code has the same result, but here the putPoints() function overwrites rather than extends:</p>
<pre class="cpp">

          <span class="type"><a href="qpolygon.html#QPolygon">QPolygon</a></span> polygon(<span class="number">3</span>);
          polygon<span class="operator">.</span>putPoints(<span class="number">0</span><span class="operator">,</span> <span class="number">3</span><span class="operator">,</span> <span class="number">4</span><span class="operator">,</span><span class="number">5</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span><span class="number">0</span><span class="operator">,</span> <span class="number">8</span><span class="operator">,</span><span class="number">9</span>);
          polygon<span class="operator">.</span>putPoints(<span class="number">1</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">6</span><span class="operator">,</span><span class="number">7</span>);

</pre>
<p><b>See also </b><a href="qpolygon.html#setPoints">setPoints</a>().</p>
<!-- @@@putPoints -->
<!-- $$$setPoint[overload1]$$$setPointintintint -->
<h3 class="fn" id="setPoint"><a name="setPoint"></a><span class="type">void</span> QPolygon::<span class="name">setPoint</span>(<span class="type">int</span> <i>index</i>, <span class="type">int</span> <i>x</i>, <span class="type">int</span> <i>y</i>)</h3>
<p>Sets the point at the given <i>index</i> to the point specified by (<i>x</i>, <i>y</i>).</p>
<p><b>See also </b><a href="qpolygon.html#point">point</a>(), <a href="qpolygon.html#putPoints">putPoints</a>(), and <a href="qpolygon.html#setPoints">setPoints</a>().</p>
<!-- @@@setPoint -->
<!-- $$$setPoint$$$setPointintconstQPoint& -->
<h3 class="fn" id="setPoint-1"><a name="setPoint-1"></a><span class="type">void</span> QPolygon::<span class="name">setPoint</span>(<span class="type">int</span> <i>index</i>, const <span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> &amp;<i>point</i>)</h3>
<p>This is an overloaded function.</p>
<p>Sets the point at the given <i>index</i> to the given <i>point</i>.</p>
<!-- @@@setPoint -->
<!-- $$$setPoints[overload1]$$$setPointsintconstint* -->
<h3 class="fn" id="setPoints"><a name="setPoints"></a><span class="type">void</span> QPolygon::<span class="name">setPoints</span>(<span class="type">int</span> <i>nPoints</i>, const <span class="type">int</span> *<i>points</i>)</h3>
<p>Resizes the polygon to <i>nPoints</i> and populates it with the given <i>points</i>.</p>
<p>The example code creates a polygon with two points (10, 20) and (30, 40):</p>
<pre class="cpp">

          <span class="keyword">static</span> <span class="keyword">const</span> <span class="type">int</span> points<span class="operator">[</span><span class="operator">]</span> <span class="operator">=</span> { <span class="number">10</span><span class="operator">,</span> <span class="number">20</span><span class="operator">,</span> <span class="number">30</span><span class="operator">,</span> <span class="number">40</span> };
          <span class="type"><a href="qpolygon.html#QPolygon">QPolygon</a></span> polygon;
          polygon<span class="operator">.</span>setPoints(<span class="number">2</span><span class="operator">,</span> points);

</pre>
<p><b>See also </b><a href="qpolygon.html#setPoint">setPoint</a>() and <a href="qpolygon.html#putPoints">putPoints</a>().</p>
<!-- @@@setPoints -->
<!-- $$$setPoints$$$setPointsintintint... -->
<h3 class="fn" id="setPoints-1"><a name="setPoints-1"></a><span class="type">void</span> QPolygon::<span class="name">setPoints</span>(<span class="type">int</span> <i>nPoints</i>, <span class="type">int</span> <i>firstx</i>, <span class="type">int</span> <i>firsty</i>, <i>...</i>)</h3>
<p>This is an overloaded function.</p>
<p>Resizes the polygon to <i>nPoints</i> and populates it with the points specified by the variable argument list. The points are given as a sequence of integers, starting with <i>firstx</i> then <i>firsty</i>, and so on.</p>
<p>The example code creates a polygon with two points (10, 20) and (30, 40):</p>
<pre class="cpp">

          <span class="type"><a href="qpolygon.html#QPolygon">QPolygon</a></span> polygon;
          polygon<span class="operator">.</span>setPoints(<span class="number">2</span><span class="operator">,</span> <span class="number">10</span><span class="operator">,</span> <span class="number">20</span><span class="operator">,</span> <span class="number">30</span><span class="operator">,</span> <span class="number">40</span>);

</pre>
<!-- @@@setPoints -->
<!-- $$$subtracted[overload1]$$$subtractedconstQPolygon& -->
<h3 class="fn" id="subtracted"><a name="subtracted"></a><span class="type"><a href="qpolygon.html#QPolygon">QPolygon</a></span> QPolygon::<span class="name">subtracted</span>(const <span class="type"><a href="qpolygon.html#QPolygon">QPolygon</a></span> &amp;<i>r</i>) const</h3>
<p>Returns a polygon which is <i>r</i> subtracted from this polygon.</p>
<p>Set operations on polygons will treat the polygons as areas. Non-closed polygons will be treated as implicitly closed.</p>
<p>This function was introduced in Qt 4.3.</p>
<!-- @@@subtracted -->
<!-- $$$swap[overload1]$$$swapQPolygon& -->
<h3 class="fn" id="swap"><a name="swap"></a><span class="type">void</span> QPolygon::<span class="name">swap</span>(<span class="type"><a href="qpolygon.html#QPolygon">QPolygon</a></span> &amp;<i>other</i>)</h3>
<p>Swaps polygon <i>other</i> with this polygon. This operation is very fast and never fails.</p>
<p>This function was introduced in Qt 4.8.</p>
<!-- @@@swap -->
<!-- $$$translate[overload1]$$$translateintint -->
<h3 class="fn" id="translate"><a name="translate"></a><span class="type">void</span> QPolygon::<span class="name">translate</span>(<span class="type">int</span> <i>dx</i>, <span class="type">int</span> <i>dy</i>)</h3>
<p>Translates all points in the polygon by (<i>dx</i>, <i>dy</i>).</p>
<p><b>See also </b><a href="qpolygon.html#translated">translated</a>().</p>
<!-- @@@translate -->
<!-- $$$translate$$$translateconstQPoint& -->
<h3 class="fn" id="translate-1"><a name="translate-1"></a><span class="type">void</span> QPolygon::<span class="name">translate</span>(const <span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> &amp;<i>offset</i>)</h3>
<p>This is an overloaded function.</p>
<p>Translates all points in the polygon by the given <i>offset</i>.</p>
<p><b>See also </b><a href="qpolygon.html#translated">translated</a>().</p>
<!-- @@@translate -->
<!-- $$$translated[overload1]$$$translatedintint -->
<h3 class="fn" id="translated"><a name="translated"></a><span class="type"><a href="qpolygon.html#QPolygon">QPolygon</a></span> QPolygon::<span class="name">translated</span>(<span class="type">int</span> <i>dx</i>, <span class="type">int</span> <i>dy</i>) const</h3>
<p>Returns a copy of the polygon that is translated by (<i>dx</i>, <i>dy</i>).</p>
<p>This function was introduced in Qt 4.6.</p>
<p><b>See also </b><a href="qpolygon.html#translate">translate</a>().</p>
<!-- @@@translated -->
<!-- $$$translated$$$translatedconstQPoint& -->
<h3 class="fn" id="translated-1"><a name="translated-1"></a><span class="type"><a href="qpolygon.html#QPolygon">QPolygon</a></span> QPolygon::<span class="name">translated</span>(const <span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> &amp;<i>offset</i>) const</h3>
<p>This is an overloaded function.</p>
<p>Returns a copy of the polygon that is translated by the given <i>offset</i>.</p>
<p>This function was introduced in Qt 4.6.</p>
<p><b>See also </b><a href="qpolygon.html#translate">translate</a>().</p>
<!-- @@@translated -->
<!-- $$$united[overload1]$$$unitedconstQPolygon& -->
<h3 class="fn" id="united"><a name="united"></a><span class="type"><a href="qpolygon.html#QPolygon">QPolygon</a></span> QPolygon::<span class="name">united</span>(const <span class="type"><a href="qpolygon.html#QPolygon">QPolygon</a></span> &amp;<i>r</i>) const</h3>
<p>Returns a polygon which is the union of this polygon and <i>r</i>.</p>
<p>Set operations on polygons, will treat the polygons as areas, and implicitly close the polygon.</p>
<p>This function was introduced in Qt 4.3.</p>
<p><b>See also </b><a href="qpolygon.html#intersected">intersected</a>() and <a href="qpolygon.html#subtracted">subtracted</a>().</p>
<!-- @@@united -->
<!-- $$$operator QVariant[overload1]$$$operator QVariant -->
<h3 class="fn" id="operator-QVariant"><a name="operator-QVariant"></a><span class="type"><a href="../qtcore/qvariant.html">QVariant</a></span> QPolygon::<span class="name">operator QVariant</span>() const</h3>
<p>Returns the polygon as a <a href="../qtcore/qvariant.html">QVariant</a></p>
<!-- @@@operator QVariant -->
</div>
<div class="relnonmem">
<h2>Related Non-Members</h2>
<!-- $$$operator<<$$$operator<<QDataStream&constQPolygon& -->
<h3 class="fn" id="operator-lt-lt-14"><a name="operator-lt-lt-14"></a><span class="type"><a href="../qtcore/qdatastream.html">QDataStream</a></span> &amp;<span class="name">operator&lt;&lt;</span>(<span class="type"><a href="../qtcore/qdatastream.html">QDataStream</a></span> &amp;<i>stream</i>, const <span class="type"><a href="qpolygon.html#QPolygon">QPolygon</a></span> &amp;<i>polygon</i>)</h3>
<p>Writes the given <i>polygon</i> to the given <i>stream</i>, and returns a reference to the stream.</p>
<p>This function was introduced in Qt 4.4.</p>
<p><b>See also </b><a href="../qtcore/datastreamformat.html">Serializing Qt Data Types</a>.</p>
<!-- @@@operator<< -->
<!-- $$$operator>>[overload1]$$$operator>>QDataStream&QPolygon& -->
<h3 class="fn" id="operator-gt-gt"><a name="operator-gt-gt"></a><span class="type"><a href="../qtcore/qdatastream.html">QDataStream</a></span> &amp;<span class="name">operator&gt;&gt;</span>(<span class="type"><a href="../qtcore/qdatastream.html">QDataStream</a></span> &amp;<i>stream</i>, <span class="type"><a href="qpolygon.html#QPolygon">QPolygon</a></span> &amp;<i>polygon</i>)</h3>
<p>Reads a polygon from the given <i>stream</i> into the given <i>polygon</i>, and returns a reference to the stream.</p>
<p>This function was introduced in Qt 4.4.</p>
<p><b>See also </b><a href="../qtcore/datastreamformat.html">Serializing Qt Data Types</a>.</p>
<!-- @@@operator>> -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2020 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
